package com.lfg.leetcode.leetcode100;

public class No189rotate {

    public static void main(String[] args) {
        int[] ret = {1,2,3,4,5,6,7};
        rotate(ret, 3);
        System.out.println(ret);
    }


    public static void rotate(int[] nums, int k) {
        int[] ret = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            int index = (i + k) % (nums.length);
            ret[index] = nums[i];
        }
        int index = 0;
        for (int i : ret) {
            nums[index++] = i;
        }
    }
}
